<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link href="css/style.css" rel="stylesheet" type="text/css">

		<s:head theme="xhtml"/>
  		<sx:head parseContent="true"/>

		<title>维护所有的入库单主表</title>
		<script type="text/javascript">
			var link;
			function buyInMainMod( link ) {
				var d = document.forms[0];
				d.action = link;
				d.submit();
			}

			function buyInMainDel( link ) {
				if (window.confirm("确认删除吗？")) {
					var d = document.forms[0];
					d.action = link;
					d.submit();
				} else {

				}
			}

		</script>
	</head>

	<body>
		<center>
			<h2>
				<s:if test = "maintainMode == 1">
					维护所有的入库单主表
				</s:if>
				<s:else>
					维护所有的入库单结账信息
				</s:else>
			</h2>
			<br/>
			
		</center>
		<div align="center">
			<form action="#" method="post">
				<s:hidden name="maintainMode"  value="%{maintainMode}" />
			
				<s:textfield label="单号" name="buyInMain.id" value="" size="6" />&nbsp;
				<s:select id="suppList" name="buyInMain.suppId" label="供应商"
								  list="%{#request.allSupp}"
								  listKey="id" listValue="shortName" />&nbsp;
				<sx:datetimepicker label="入库日期" name="buyInMain.buyDate"
							   displayFormat="yy-MM-dd" />&nbsp;

				<s:if test = "maintainMode == 1">
					<s:textfield label="经手人" name="buyInMain.handler" size="8" />&nbsp;
				</s:if>
				<s:else>
					<s:select id="ifSettle" name="buyInMain.ifSettle" label="是否结清"
								  list="#{'1':'未结清', '2':'已结清'}"
								  listKey="key" listValue="value" />&nbsp;
				</s:else>

				<input type="button" value="查询"     name="queryByCond" onclick="buyInMainMod( 'selectBuyInMainByCond' )" />&nbsp;
				<s:if test = "maintainMode == 1">
					<input type="button" value="查询全部" name="queryAll"    onclick="buyInMainMod( 'queryAllBuyInMain' )" />
						<!-- 借用一下 这个函数 -->
				</s:if>


				<table border="1" width="80%">
					<tr>
						<th>单号</th>
						<th>供应商</th>
						<th>入库日期</th>
						<th>经手人</th>
						<th>结算方式</th>
						<th>操作员</th>
						<th>维护</th>

					</tr>
					<s:iterator value="#request.buyInMainList" id="buyInMain">
						<tr>
							<td>
								<s:property value="#buyInMain.id" />
							</td>
							<td>
								<s:property value="#buyInMain.suppName" />
							</td>
							<td>
								<s:property value="#buyInMain.buyDate" />
							</td>
							<td>
								<s:property value="#buyInMain.handler" />
							</td>
							<td>
								<s:property value="#buyInMain.settleMode" />
							</td>
							<td>
								<s:property value="#buyInMain.operator" />
							</td>
							<td>
								<s:if test = "maintainMode == 1">
									<input type="button" value="修改" name="update" onclick="buyInMainMod('prepareModBuyInMain?buyInMainId=<s:property value="#buyInMain.id" />')" />
									<input type="button" value="删除" name="delete" onclick="buyInMainDel('deleteBuyInMain?buyInMainId=<s:property value="#buyInMain.id" />')" />
									<input type="button" value="明细" name="detail" onclick="buyInMainMod('queryAllBuyInDetail?buyInMainId=<s:property value="#buyInMain.id" />')" />
								</s:if>
								<s:else>
									<input type="button" value="结账" name="settle" onclick="buyInMainMod('queryAllBuyInSettle?buyInMainId=<s:property value="#buyInMain.id" />')" />
								</s:else>
							
							</td>
						</tr>
					</s:iterator>
				</table>
			</form>

			<br/>
			<s:if test = "maintainMode == 1">
				<a href="prepareAddBuyInMain.action">新增入库单</a>
			</s:if>

		</div>
	</body>
</html>